/**
 * 闭包
 */
(function () {

    // 严格模式
    "use strict";

    angular
        .module('app.hr')
        .controller('AttendanceRecordAddController', attendanceRecordAddController);

     attendanceRecordAddController.$inject = ['$scope', '$state', '$q', '$filter', '$log', 'Restangular', 'ngNotify',
        'Tools'];

    /**
     * 控制器
     */
    function  attendanceRecordAddController($scope, $state, $q, $filter, $log, Restangular, ngNotify, Tools) {
        // 先赋给vm
        $log.debug('AttendanceRecordAddController');
        var vm = this;
        vm.data = {};
        vm.save = function() {
            $log.debug('save');
            Restangular
                .all('hr')
                .all('attendanceRecord')
                .post(vm.data)
                .then(function(result) {
                    // 画面跳转
                    $state.go('app.hr.attendancerecord');
                })
                .catch(function(result){
                    var msg = result.message;
                    ngNotify.set(msg, 'error');
                });
        };
        vm.back = function() {
            Tools.back('app.hr.attendancerecord');
        };
        //职员
        vm.employees = [];
        //职员取得
        Restangular
            .all('base')
            .all('employee')
            .getList()
            .then(function (result) {
                vm.employees = result;
            });
    }

})();